﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>附件</title>
    <meta charset="UTF-8" />
    <base target="_self" />
    <script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-form.js" type="text/javascript"></script>

    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="../Comm/Gener.js" type="text/javascript"></script>
    <script src="../Scripts/slideBox/jquery.slideBox.min.js" type="text/javascript"></script>
    <script src="Ath.js" type="text/javascript"></script>


    <script src="../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../Comm/JS/Calendar/WdatePicker.js" type="text/javascript" defer="defer"></script>
    <script src="JS/FileUpload/fileUpload.js" type="text/javascript"></script>
    <link href='JS/FileUpload/css/fileUpload.css' rel='stylesheet' type='text/css' />

    <script src="../Admin/CCFlowEnum.js" type="text/javascript"></script>
    <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.css" rel="stylesheet"
          type="text/css" />
    <script src="../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/bootstrap-table/src/locale/bootstrap-table-zh-CN.js"
            type="text/javascript"></script>
    <!-- 导入可以扩展的按钮事件. -->
    <script src="../../DataUser/OverrideFiles/Ath.js" type="text/javascript"></script>

    <style type="text/css">
        .table > thead > tr > td, .table > tbody > tr > td {
            border: 1px solid #ddd;
        }

        .table > thead > tr > th {
            border-bottom: 1px solid #ddd;
        }

        .image-item {
            width: 75px !important;
            height: 75px;
            background-image: url(./ImgAth/css/images/iconfont-tianjia.png);
            background-size: 100% 100%;
            display: inline-block;
            position: relative;
            border-radius: 5px;
            margin-right: 10px;
            margin-bottom: 10px;
            border: solid 1px #e8e8e8;
            float: left;
        }

            .image-item input[type="file"] {
                position: absolute;
                left: 0px;
                top: 0px;
                width: 100%;
                height: 100%;
                opacity: 0;
                cursor: pointer;
                z-index: 0;
            }

            .image-item .image-close {
                position: absolute;
                display: inline-block;
                right: -6px;
                top: -6px;
                width: 20px;
                height: 20px;
                text-align: center;
                line-height: 20px;
                border-radius: 12px;
                background-color: #FF5053;
                color: #f3f3f3;
                border: solid 1px #FF5053;
                font-size: 9px;
                font-weight: 200;
                z-index: 1;
            }

        .form-control {
            display: inline;
            width: auto;
            height: 40px;
        }

        .uploadBts {
            height: 30px !important;
            width: 85px !important;
        }

        .selectFileBt {
            height: 30px;
            line-height: 10px;
            width: 82px;
            background-color: white !important;
            color: black !important;
            border: 1px solid black !important;
            font-size: 14px !important;
            font-weight: normal;
        }
    </style>
    <script language="javascript" type="text/javascript">
        var numOfUpload = 0;  //要求上传的最小数量.
        var topNumOfUpload = 0;  //要求上传的最大数量.
        var fileMaxSize = 0;  //要求上传的最大附件大小.
        var numOfAths = 0;    //附件数量.
        function CanEditor(fileType) {

            var fileTypes = "";
            if (fileTypes == null || fileTypes == "")
                fileTypes = "doc,docx,pdf,xls,xlsx,txt";

            if (fileTypes.indexOf(fileType.toLowerCase()) != -1)
                return true;
            else
                return false;
        }
        function IsImgExt(ext) {
            ext = ext.replace(".", "").toLowerCase();
            switch (ext) {
                case "gif":
                case "jpg":
                case "jepg":
                case "jpeg":
                case "bmp":
                case "png":
                case "tif":
                case "gsp":
                case "mov":
                case "psd":
                case "tiff":
                case "wmf":
                    return true;
                default:
                    return false;
            }
        }

        function GetSortLenth_FromDB(sort, dbs) {
            var sortLength = 0;
            for (var p = 0; p < dbs.length; p++) {
                if (dbs[p].Sort == sort) sortLength++;
            }
            return sortLength;
        }

        var Ath;
        var FK_MapData;
        var FK_FrmAttachment;
        var WorkID;
        var FK_Node;
        var PKVal;
        var IsReadonly;
        var FID;
        var EnsName;
        var FK_Flow;
        //页面启动函数.
        var WebUser = new WebUser();
        var data;
        var athDesc;
        var athSortNum = [];

        //文件上传执行的URL
        var uploadUrl = "";

        //检查上传的附件数量是否符合要求
        function CheckAthNum() {

            if (numOfUpload > numOfAths) {
                return "上传附件数量不能小于" + numOfUpload;
            }

            //判断附件上传最大数量
            if (topNumOfUpload < numOfAths) {
                return "您最多上传[" + topNumOfUpload + "]个附件";
            }

            if (athSortNum.length != 0 && athDesc.UploadFileNumCheck == 2) {
                var msg = "";
                for (var idx = 0; idx < athSortNum.length; idx++) {
                    if (athSortNum[idx].Num == 0)
                        msg += athSortNum[idx].Sort + ",";
                }
                if (msg != "") {
                    return msg.substring(0, msg.length - 1) + "分组至少上传一个附件";
                }
                return "";


            }

            return "";
        }

        $(function () {

            Ath = GetQueryString("Ath");
            FK_MapData = GetQueryString("FK_MapData");
            FK_FrmAttachment = GetQueryString("FK_FrmAttachment");
            PKVal = GetQueryString("PKVal");
            FK_Node = GetQueryString("FK_Node");
            WorkID = GetQueryString("WorkID");
            IsReadonly = GetQueryString("IsReadonly");
            FID = GetQueryString("FID");
            EnsName = GetQueryString("EnsName");
            FK_Flow = GetQueryString("FK_Flow");

            if (WorkID == "undefined" || WorkID == null || WorkID == "")
                WorkID = GetQueryString("OID");
            if (WorkID == "undefined" || WorkID == null || WorkID == "")
                WorkID = GetQueryString("PKVal");

            //关闭上传进度条
            if (GetQueryString('IsExtend') != undefined && GetQueryString('IsExtend') == "1") {
                $('#bar').css('display', 'block');
                $('#btn_Colse').bind('click', close);
            }
            $('#btn_Colse').bind('click', close);

            //获取上传附件列表的信息及权限信息
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
            handler.AddUrlData();
            data = handler.DoMethodReturnString("Ath_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                window.location.href = url;
                return;
            }

            data = JSON.parse(data);

            athDesc = data["AthDesc"][0];

            //自定义表单模式.
            if (athDesc.AthRunModel == 2) {
                src = "../../DataUser/OverrideFiles/AthSelf.htm?PKVal=" + GetPKVal() + "&Ath=" + athDesc.NoOfObj + "&FK_MapData=" + athDesc.FK_MapData + "&FK_FrmAttachment=" + athDesc.MyPK;
                window.location.href = src;
                return;
            }

            var dbs = data["DBAths"];

            var fileShowWay = athDesc.FileShowWay;
            if (fileShowWay == "undefined" || fileShowWay == null || fileShowWay == "")
                fileShowWay = 0;

            //用于必须上传的校验.
            numOfUpload = athDesc.NumOfUpload; //最低上传的数量.
            topNumOfUpload = athDesc.TopNumOfUpload; //最大上传的数量.
            fileMaxSize = athDesc.FileMaxSize; //最大上传的附件大小.
            numOfAths = dbs.length; //现有的数量.

            var mapAttrs = null;

            //如果是图片附件
            if (athDesc.FileType == 1) {
                FileShowPic(athDesc, dbs);
            }
            else {//普通附件
                if (athDesc.IsExpCol != 0) { //是个启用扩展字段
                    mapAttrs = new Entities("BP.Sys.MapAttrs");
                    var extMapData = GetQueryString("FK_MapData") + "_" + athDesc.NoOfObj;
                    mapAttrs.Retrieve("FK_MapData", extMapData);
                }


                //表格方式
                if (fileShowWay == FileShowWay.Table)
                    FileShowWayTable(athDesc, dbs, mapAttrs);
            }



            if (plant == 'CCFlow')
                uploadUrl = basePath + '/WF/CCForm/Handler.ashx?AttachPK=' + FK_FrmAttachment + '&DoType=MoreAttach&EnsName=' + EnsName + '&FK_Flow=' + FK_Flow + '&PKVal=' + PKVal;
            else {
                uploadUrl = basePath + "/WF/Ath/AttachmentUploadS.do?FK_FrmAttachment=" + FK_FrmAttachment + '&FK_Flow=' + FK_Flow + "&PKVal=" + PKVal;
            }
            uploadUrl += "&WorkID=" + GetQueryString("WorkID");
            uploadUrl += "&FID=" + GetQueryString("FID");
            uploadUrl += "&FK_Node=" + GetQueryString("FK_Node");
            uploadUrl += "&PWorkID=" + GetQueryString("PWorkID");
            uploadUrl += "&FK_MapData=" + GetQueryString("FK_MapData");

            var realFileExts = athDesc.Exts;
            if (realFileExts == null || realFileExts == "" || realFileExts == "*.*")
                realFileExts = "*";
            else {
                realFileExts = realFileExts.replace(/\s*/g, "").replace(/[*.]/g, "").split(",");
            }

            /*if(IsIELower10 == false)*/
            $("#fileUploadContent").initUpload({
                //"uploadId":athDesc.MyPK,
                "uploadUrl": uploadUrl,//上传文件信息地址
                "progressUrl": "#",//获取进度信息地址，可选，注意需要返回的data格式如下（{bytesRead: 102516060, contentLength: 102516060, items: 1, percent: 100, startTime: 1489223136317, useTime: 2767}）
                "showSummerProgress": false,//总进度条，默认限制
                "size": athDesc.FileMaxSize,//文件大小限制，单位kb,默认不限制
                //"maxFileNumber":3,//文件个数限制，为整数
                //"filelSavePath":realFileExts,//文件上传地址，后台设置的根目录
                "ismultiple": true,
                "beforeUpload": beforeUploadFun,//在上传前执行的函数
                "onUpload": function (opt, data) {
                    uploadTools.uploadError(opt);//显示上传错误
                    window.location.href = window.location.href;
                },//在上传后执行的函数
                autoCommit: true,//文件是否自动上传
                "fileType": realFileExts//文件类型限制，默认不限制，注意写的是文件后缀
            });

            setIframeHeight();

        });

        //在上传前执行的函数
        function beforeUploadFun(opt) {
            if (parseInt(athDesc.IsExpCol) == 0) {
                var sort = $("#Sort").val();
                if (sort != null && sort != "" && sort != undefined)
                    opt.otherData = [{ "name": "Sort", "value": sort }];
            }
            if (parseInt(athDesc.IsExpCol) == 1) {
                var parasData = $("form").serialize();
                parasData = decodeURIComponent(parasData, true);
                parasData = parasData.replace(/&/g, '@');
                parasData = parasData.replace(/TB_/g, '');
                parasData = parasData.replace(/RB_/g, '');
                parasData = parasData.replace(/CB_/g, '');
                parasData = parasData.replace(/DDL_/g, '');
                //获取分组
                var sort = $("#Sort").val();
                if (sort != null && sort != "" && sort != undefined)
                    opt.otherData = [{ "name": "Sort", "value": sort }];

                opt.otherData = [{ "name": "parasData", "value": parasData }];
            }
        }
        //Table模式
        var columnNum = 6;
        function FileShowWayTable(athDesc, dbs, mapAttrs) {
            //var html = "<table class='table' >";
            var html = "";
            html += "<thead>";
            if (athDesc.IsShowTitle == 1) {
                html += "<tr style='border:0px;'>";
                html += "<th  style='line-height:30px;width:50px; border: 1px solid #ddd' nowrap=true >序</td>";
                if (athDesc.Sort != null && athDesc.Sort.indexOf(",") != -1) {
                    var sortColumn = athDesc.Sort.indexOf("@") != -1 ? athDesc.Sort.substring(0, athDesc.Sort.indexOf("@")) : "类别";
                    if (sortColumn == "")
                        sortColumn = "类别";
                    html += "<th style='line-height:30px; border-top: 1px solid #ddd;width:120px' nowrap=true >" + sortColumn + "</td>";

                }

                //是否启用附件从表 0 禁用 1启用
                if (athDesc.IsExpCol == 0) {

                    html += "<th style='line-height:30px;min-width:200px; border: 1px solid #ddd' nowrap=true >文件名<div style='float:right' id='fileUploadContent' class='fileUploadContent'></div> </th>";
                    html += "<th  style='line-height:30px;width:50px; border: 1px solid #ddd' nowrap=true >大小KB</th>";
                    html += "<th  style='line-height:30px;width:120px; border: 1px solid #ddd' nowrap=true >上传时间</th>";
                    html += "<th  style='line-height:30px;width:80px; border: 1px solid #ddd' nowrap=true >上传人</th>";
                } else {

                    html += "<th nowrap=true style='line-height:30px;border: 1px solid #ddd;width:200px' >文件名<div style='float:right' id='fileUploadContent' class='fileUploadContent'></div></th>";
                    html += "<th nowrap=true style='line-height:30px;border: 1px solid #ddd;width:50px' >大小KB</th>";
                    html += "<th nowrap=true style='line-height:30px;border: 1px solid #ddd;width:120px' >上传时间</th>";
                    html += "<th nowrap=true style='line-height:30px;border: 1px solid #ddd;width:80px' >上传人</th>";


                    for (var ii = 0; ii < mapAttrs.length; ii++) {
                        var attr = mapAttrs[ii];
                        if (attr.UIIsInput == 1 && attr.UIIsEnable == 1)
                            html += "<th nowrap=true style='border: 1px solid #ddd;'><span style='color:red' class='mustInput' data-keyofen='" + attr.KeyOfEn + "' >*</span>";
                        else
                            html += "<th nowrap=true style='border: 1px solid #ddd;'>";
                        if (attr.UIContralType == 0)
                            html += "<label for='TB_" + attr.KeyOfEn + "' class='" + (attr.UIIsInput == 1 ? "mustInput" : "") + "' >" + attr.Name + "</label></th>";

                        if (attr.UIContralType == 1)
                            html += "<label for='DDL_" + attr.KeyOfEn + "' class='" + (attr.UIIsInput == 1 ? "mustInput" : "") + "' >" + attr.Name + "</label></th>";
                        if (attr.UIContralType == 2)
                            html += "<label for='TB_" + attr.KeyOfEn + "' class='" + (attr.UIIsInput == 1 ? "mustInput" : "") + "'  >" + attr.Name + "</label></th>";
                        //
                        if (attr.UIContralType == 3)
                            html += "<label for='RB_" + attr.KeyOfEn + "' class='" + (attr.UIIsInput == 1 ? "mustInput" : "") + "'  >" + attr.Name + "</label></th>";

                    }
                    columnNum = columnNum + mapAttrs.length;
                }
                html += "<th  nowrap=true style='line-height:30px; border: 1px solid #ddd;width:100px' >";

                if (athDesc.IsDownload == 1 && dbs.length > 0)
                    html += "<a href='javascript:DownZip()' ><img src='../Img/FileType/zip.png' style='width:16px;height:16px;' alt='打包下载' /></a>";
                else
                    html += "操作";

                html += "</th>";
                html += "</thead>";
            }

            html += "<tbody>";
            var i = 0;
            var fileSorts = new Array("");
            var haveAuthSort = false;
            var bSort_Add_TD = false;

            //存在分組
            if (athDesc.Sort != null) {
                haveAuthSort = true;
                //追加一个空项
                if (athDesc.Sort.lastIndexOf(",") + 1 != athDesc.Sort.length)
                    athDesc.Sort = athDesc.Sort + ",";
                fileSorts = athDesc.Sort.split(',');
            }

            //循环分组
            var haveFileSort = "";
            for (var j = 0; j < fileSorts.length; j++) {
                //判断分组是否有文件
                var IsExistFile = false;
                var sortNum = 0;
                var sort = fileSorts[j]
                if (fileSorts.length > 1 && sort == "")
                    continue;
                bSort_Add_TD = true;

                var mysort = sort;
                if (sort.indexOf("@") != -1)
                    mysort = sort.substring(sort.indexOf('@') + 1);

                for (var k = 0; k < dbs.length; k++) {
                    var db = dbs[k];
                    if (haveAuthSort == true && db.Sort != mysort)
                        continue;
                    IsExistFile = true;
                    haveFileSort += db.Sort + ",";
                    i++;
                    sortNum++;
                    html += "<tr>";
                    html += "<td class='Idx' nowrap>" + i + "</td>";
                    if (athDesc.Sort != null && athDesc.Sort.indexOf(",") != -1) {
                        if (bSort_Add_TD == true) {
                            bSort_Add_TD = false;
                            var rowSpan = GetSortLenth_FromDB(mysort, dbs);
                            html += "<td rowspan=" + rowSpan + ">" + db.Sort + "</td>";
                        }
                    }
                    if (athDesc.IsDownload == 1) {
                        if (athDesc.IsWoEnableWF && CanEditor(db.FileExts))
                            html += addTdTitle(db.FileName, "<a href=\"javascript:AthView('" + FK_FrmAttachment + "','" + PKVal + "','" + db.MyPK + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                        else if (IsImgExt(db.FileExts) == true)
                            html += addTdTitle(db.FileName, "<a href=\"javascript:AthView('" + FK_FrmAttachment + "','" + PKVal + "','" + db.MyPK + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                        else
                            html += addTdTitle(db.FileName, "<a href=\"javascript:AthView('" + FK_FrmAttachment + "','" + PKVal + "','" + db.MyPK + "');\" ><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                    }
                    else
                        html += "<td><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</td>";

                    html += "<td>" + db.FileSize + "</td>";
                    html += "<td>" + db.RDT + "</td>";
                    html += "<td>" + db.RecName + "</td>";

                    //如果有数据,就要解析它附件属性.
                    if (athDesc.IsExpCol == 1) {


                        for (var ii = 0; ii < mapAttrs.length; ii++) {
                            var mapAttr = mapAttrs[ii];
                            var defVal = GetPara(mapAttr.KeyOfEn, db.AtPara);
                            if (mapAttr.MyDataType == 2 && mapAttr.LGType == 1) {
                                var senum = new Entity("BP.Sys.SysEnum", mapAttr.UIBindKey + "_CH" + "_" + defVal);
                                defVal = senum.Lab;
                            }
                            if (mapAttr.MyDataType == 4) {
                                if (defVal == "on") defVal = "是";
                                else defVal = "否";
                            }

                            html += "<td>" + defVal + "</td>";
                            //html += "<td></td>";
                        }
                    }
                    //输出操作部分.
                    html += "<td>";
                    if (athDesc.IsDownload == 1)
                        html += "<a href=\"javascript:Down2018('" + FK_FrmAttachment + "','" + PKVal + "','" + db.MyPK + "')\">下载</a>";
                    if (IsReadonly != "1") {
                        var op = "";

                        if (athDesc.DeleteWay == AthDeleteWay.DelAll)//删除所有
                            op = "&nbsp;&nbsp;&nbsp;<a href=\"javascript:Del('" + FK_FrmAttachment + "','" + PKVal + "','" + db.MyPK + "')\">删除</a>";
                        if (athDesc.DeleteWay == AthDeleteWay.DelSelf)//删除自己上传的
                            if (db.Rec == WebUser.No)
                                op = "&nbsp;&nbsp;&nbsp;<a href=\"javascript:Del('" + FK_FrmAttachment + "','" + PKVal + "','" + db.MyPK + "')\">删除</a>";

                        html += op;
                    }

                    html += "</td>";

                    html += "</tr>";
                }

                if (IsExistFile == false) {
                    i++;
                    //组合Html
                    html += "<tr>";
                    html += "<td class='Idx' nowrap>" + i + "</td>";
                    if (fileSorts.length > 1)
                        html += "<td>" + sort + "</td>";
                    if (athDesc.IsUpload == true && IsReadonly != "1")
                        html += "<td style='width:100px;color:red'>请上传附件..</td>";
                    else
                        html += "<td style='width:100px;color:red'></td>";
                    html += "<td>&nbsp&nbsp</td>";
                    html += "<td>&nbsp&nbsp</td>";
                    html += "<td>&nbsp&nbsp</td>";
                    //如果有数据,就要解析它附件属性.
                    if (athDesc.IsExpCol == 1) {

                        for (var ii = 0; ii < mapAttrs.length; ii++) {

                            html += "<td>" + InitAthMapAttrOfCtrlFool("", mapAttrs[ii]) + "</td>";
                        }
                    }
                    if (athDesc.IsExpCol == 1)
                        html += "<td><a href='javaScript:void(0)' onclick='changeSort(\"" + sort + "\")'>上传</a>&nbsp;&nbsp;&nbsp;<a href=\"\" onclick=\"return SaveUpload()\">保存</a></td>";
                    else {
                        var explorer = window.navigator.userAgent;
                        var isIE = explorer.indexOf("compatible") > -1 && explorer.indexOf("MSIE") > -1; //判断是否IE<11浏览器
                        if (((explorer.indexOf('MSIE') >= 0) && (explorer.indexOf('Opera') < 0) || (explorer.indexOf('Trident') >= 0)))
                            html += "<td></td>";
                        else {
                            if (athDesc.IsUpload == true && IsReadonly != "1") {
                                //html += "<td><a href='javaScript:void(0)' onclick='changeSort(\"" + sort + "\")'>上传</a></td>";
                                html += "<td> - </td>";
                            }
                            else
                                html += "<td></td>";
                        }
                    }
                    html += "</tr>";
                }
                athSortNum.push({ "Sort": mysort, "Num": sortNum });
            }
            if ((i == 0 && (athDesc.Sort == null || athDesc.Sort.indexOf(",") == -1)) || (athDesc.IsExpCol == 1 && athDesc.IsUpload == true)) {
                html += "<tr>";
                html += "<td class='Idx' nowrap>*</td>";;

                if (athDesc.IsUpload == true)
                    html += "<td style='width:100px'> </td>";
                else
                    html += "<td style='width:100px'></td>";
                html += "<td>&nbsp&nbsp</td>";
                html += "<td>&nbsp&nbsp</td>";
                html += "<td>&nbsp&nbsp</td>";

                //如果有数据,就要解析它附件属性.
                if (athDesc.IsExpCol == 1) {

                    for (var ii = 0; ii < mapAttrs.length; ii++) {

                        html += "<td>" + InitAthMapAttrOfCtrlFool("", mapAttrs[ii]) + "</td>";
                    }
                }
                if (athDesc.IsExpCol == 1)
                    html += "<td><a href='javaScript:void(0)' onclick='changeSort()'>上传</a>&nbsp;&nbsp;&nbsp;<a href=\"\" onclick=\"return SaveUpload()\">保存</a></td>";
                else
                    html += "<td>&nbsp&nbsp</td>";
                html += "</tr>";
            }

            html += AddFileUpload(athDesc);
            html += "</tbody>";

            $("#ShowTable").html(html);

            //隐藏他，如果不能上传.
            if (athDesc.IsUpload == 0)
                $("#fileUploadContent").hide();
        }


        //增加文件名称
        function addTdTitle(title, str) {
            return "\n<td  nowrap title='" + title + "' >" + str + "</td>";
        }


        function AddFileUpload(athDesc) {
            var html = "";
            if (athDesc.IsUpload == true && IsReadonly != "1") {
                html += "<tr>";
                if (athDesc.Sort != null && athDesc.Sort.indexOf(",") != -1)
                    html += "<td colspan=" + (columnNum + 1) + ">";
                else
                    html += "<td colspan=" + columnNum + ">";


                var explorer = window.navigator.userAgent;

                html += "<div id='file_upload-queue' class='uploadify-queue'></div>";

                if (athDesc.Sort != null && athDesc.Sort.indexOf(",") != -1) {
                    var sortColumn = athDesc.Sort.indexOf("@") != -1 ? athDesc.Sort.substring(0, athDesc.Sort.indexOf("@")) : "类别";
                    var strs = athDesc.Sort.indexOf("@") != -1 ? athDesc.Sort.substring(athDesc.Sort.lastIndexOf("@") + 1).split(',') : athDesc.Sort.split(',');
                    var operations = "";
                    for (var idx = 0; idx < strs.length; idx++) {
                        operations += "<option  value='" + strs[idx] + "'>" + strs[idx] + "</option>";
                    }
                    html += "<div id='s' style='text-align:left;float:left;display:inline;width:100%'  >";
                    html += "<div style='float:left;padding-right:2px'>";
                    html += "请选择" + sortColumn + "：";
                    html += "<select id='Sort' class='form-control'>" + operations + "</select>";
                    html += "</div>";
                }
                else {
                    html += "<div id='s' style='text-align:left;float:left;display:inline;width:100%' >";
                }


                html += "</div>";

                if (athDesc.IsNote)
                    html += "<input type='text' id='TB_Note' style='width:90%;display:none;' size='30'/>";
                html += "</div>";
                html += "</td>";
                html += "</tr>";
            }
            return html;
        }

        //在线预览，如果需要连接其他的文件预览查看器，就需要在这里重写该方法.
        function AthView(fk_ath, pkVal, delPKVal) {

            if (typeof AthViewOverWrite === 'function') {
                AthViewOverWrite(fk_ath, pkVal, delPKVal);
                return;
            }

            //AthViewOverWrite(fk_ath, pkVal, delPKVal)
            //alert(fk_ath + pkVal + delPKVal + ":AthView执行成功.");
            //AthView(fk_ath, pkVal, delPKVal);
            //return;

            if (plant == "CCFlow")
                window.location.href = basePath + '/WF/CCForm/DownFile.aspx?DoType=Down&DelPKVal=' + delPKVal + '&FK_FrmAttachment=' + fk_ath + '&PKVal=' + pkVal + '&FK_Node=' + FK_Node + '&FK_Flow=' + FK_Flow + '&FK_MapData=' + FK_MapData + '&Ath=' + Ath;
            else {
                var currentPath = window.document.location.href;
                var path = currentPath.substring(0, currentPath.indexOf('/WF') + 1);
                Url = path + 'WF/Ath/downLoad.do?DelPKVal=' + delPKVal + '&FK_FrmAttachment=' + fk_ath + '&PKVal=' + pkVal + '&FK_Node=' + FK_Node + '&FK_Flow=' + FK_Flow + '&FK_MapData=' + FK_MapData + '&Ath=' + Ath;
                window.location.href = Url;
            }
        }

        function changeSort(sort) {
            $("#Sort").val(sort);
            //激活上传文件
            $("#fileUploadContent .uploadBts .selectFileBt").click()

        }

        //上传.
        function Upload() {

            try {

                if (OnUploadClick() == false)
                    return false;
            } catch (e) {
                //alert(e);
                //return;
            }
        }
        function SaveUpload() {

            //必填项和正则表达式检查
            var formCheckResult = true;

            if (checkBlanks() == false) {
                formCheckResult = false;
            }

            if (checkReg() == false) {
                formCheckResult = false;
            }

            if (formCheckResult == false) {
                alert("请检查表单必填项和正则表达式");
                return false;
            }

            var explorer = window.navigator.userAgent;
            var isIE = explorer.indexOf("compatible") > -1 && explorer.indexOf("MSIE") > -1; //判断是否IE<11浏览器
            if (((explorer.indexOf('MSIE') >= 0) && (explorer.indexOf('Opera') < 0) || (explorer.indexOf('Trident') >= 0))) {
                $('#uploadfile').uploadify("upload", "*");
                return;
            }

            UploadChange();
        }
        function UploadChange() {
            debugger
            var fileObj = $("#file").val();
            if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
                alert("请选择上传的文件.");
                return;
            }
            //var fileName = fileObj.name;
            ////判断附件上传大小的限制
            //var fileSize = fileObj.size;
            //if (fileSize > fileMaxSize * 1024) {
            //    alert("附件大小超过了" + fileMaxSize + "KB的限制！");
            //    return;
            //}
            ////判断附件上传最大数量
            //if (topNumOfUpload <= numOfAths) {
            //    alert("您最多上传[" + topNumOfUpload + "]个附件");
            //    return;
            //}

            //if (realFileExts != "*.*" && realFileExts.indexOf(fileName.substr(fileName.lastIndexOf('.')).toLowerCase()) == -1) {
            //    alert("上传附件类型不正确，只能上传" + realFileExts);
            //    return;
            //}

            //form表单序列话
            var parasData = $("form").serialize();
            //form表单序列化时调用了encodeURLComponent方法将数据编码了
            parasData = decodeURIComponent(parasData, true);
            parasData = decodeURIComponent(parasData, true);
            parasData = parasData.replace(/&/g, '@');
            parasData = parasData.replace(/TB_/g, '');
            parasData = parasData.replace(/RB_/g, '');
            parasData = parasData.replace(/CB_/g, '');
            parasData = parasData.replace(/DDL_/g, '');

            //提交数据
            var option = {
                url: uploadUrl,
                type: 'POST',
                dataType: 'json',
                headers: { "ClientCallMode": "ajax" },
                success: function (data) {
                    if (data != null && data.indexOf("err@") != -1) {
                        alert(data.replace("err@", ""));
                        return;
                    }
                    window.location.href = window.location.href;
                }

            };

            $("#Ath_Form").ajaxSubmit(option);
            return false;


        }


        // 上传Img.
        function UploadImg() {
        }

        //关闭窗口  适用于扩展属性
        function close() {
            if (parent != undefined && parent.SetAth != undefined && typeof (parent.SetAth) == "function") {
                var nameTds = $('.Idx').next();
                var nameStrs = [];
                $.each(nameTds, function (i, nameTd) {
                    nameStrs.push($(nameTd).children('a').text());
                })
                parent.SetAth(nameStrs);
            }
        }


    </script>
    <script src="JS/FileUpload/fileUpload.js"></script>
</head>
<body>
    <form id="Ath_Form" enctype="multipart/form-data" method="post">
        <div id="Msg"></div>
        <div style="width: 99%">
            <table id="ShowTable" class="table"></table>
        </div>
        <div style="width: 99%" id="FilePic"></div>
        <div id="bar" style="display: none; position: fixed; bottom: 0px; right: 0px;">
            <button class="btn btn-info" id="btn_Colse" style="border: 0; background: #2884fa;
            color: #FFF; font-size: 12px; padding: 6px 10px; border-radius: 15px; margin: 5px;">
                关闭
            </button>
        </div>
    </form>
    <iframe width='0' height='0' frameborder='0' name="hrong" style="display: none">
    </iframe>
</body>
</html>
